class Keploy < Formula
  desc "Testing Toolkit creates test-cases and data mocks from API calls, DB queries"
  homepage "https://keploy.io"
  url "https://github.com/keploy/keploy/archive/refs/tags/v2.9.2.tar.gz"
  sha256 "f6f37bf28bed27eba24544ca43e2f469575669861936a337ad62b21f6591a34c"
  license "Apache-2.0"
  head "https://github.com/keploy/keploy.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sequoia: "823cd8f71bdc3178b210a97233a24c3dacc2dd4cc250234570412523a68c7cc5"
    sha256 cellar: :any_skip_relocation, arm64_sonoma:  "823cd8f71bdc3178b210a97233a24c3dacc2dd4cc250234570412523a68c7cc5"
    sha256 cellar: :any_skip_relocation, arm64_ventura: "823cd8f71bdc3178b210a97233a24c3dacc2dd4cc250234570412523a68c7cc5"
    sha256 cellar: :any_skip_relocation, sonoma:        "27f7accc8ceb7097ae177022018c8152803bb803cc71a835737bb91dc83049c4"
    sha256 cellar: :any_skip_relocation, ventura:       "27f7accc8ceb7097ae177022018c8152803bb803cc71a835737bb91dc83049c4"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "abf62f4101a5b183837eec51ceb3b2ee7073afe4634f264fa772b1c5ff3d5c77"
  end

  depends_on "go" => :build

  def install
    system "go", "build", *std_go_args(ldflags: "-s -w -X main.version=#{version}")
  end

  test do
    system bin/"keploy", "config", "--generate", "--path", testpath
    assert_match "# Generated by Keploy", (testpath/"keploy.yml").read

    output = shell_output("#{bin}/keploy templatize --path #{testpath}")
    assert_match "No test sets found to templatize", output

    assert_match version.to_s, shell_output("#{bin}/keploy --version")
  end
end
